package com.bjpowerrnode.streamTest;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class HParallel {
    public static void main(String[] args) {
        /**
         * parallelStream 是流并行处理程序的代替方法。以下实例我们使用 parallelStream 来输出空字符串的数量：
         */
        List<String> stringList = Arrays.asList("abc", "", "bc", "efg", "abcd", "", "jkl");
        long count = stringList.parallelStream().filter(string -> string.isEmpty()).count();
        System.out.println(count);
        stringList.parallelStream().filter(s -> !s.isEmpty()).collect(Collectors.toList()).forEach(System.out::println);
    }
}
